package com.example.coco.Controller;


import com.example.coco.res.CusumerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@RestController
public class Log {
    @Autowired
    CusumerMapper cusumerMapper;
    @RequestMapping("/login")
    public Object requestLog(@RequestParam Map<String, Object> params) {
        String id = (String) params.get("userid");
        String password = cusumerMapper.findlog(id);
        String newpassword = (String) params.get("userpassword");
        if (id == null || id.isEmpty() || password == null || password.isEmpty() || newpassword == null || newpassword.isEmpty() || !password.equals(newpassword)) {
            System.out.println("请重新输入用户名和密码");
            return new ModelAndView("loginError");
        }else if (password.equals(newpassword)) {
            System.out.println("登录成功");
            return new ModelAndView("index2");
        }
        System.out.println("404");
        return "连接超时";
    }


}
//        return cusumerMapper.findlog(userid);